package com.test;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class MenuHandler {

	private static MenuHandler instance;

	private MenuHandler() {

	}

	public static MenuHandler getHandler() {
		if (instance == null) {
			synchronized (MenuHandler.class) {
				if (instance == null) {
					instance = new MenuHandler();
				}
			}
		}
		return instance;
	}

	public String createMenu(String accessToken) throws Exception {
		return WeiXinHttpHelper.createMenu(getMenuStr(), accessToken);
	}

	private String getMenuStr() {
		JSONObject menu = new JSONObject();
		JSONArray buttons = new JSONArray();
		menu.put("button", buttons);
		
		JSONObject btn1 = new JSONObject();
		btn1.put("type", "click");
		btn1.put("name", "click");
		btn1.put("key", "KEY_TEST");
		buttons.add(btn1);
		
		JSONObject btn2 = new JSONObject();
		btn2.put("type", "view");
		btn2.put("name", "首页");
		btn2.put("url", "http://www.yint.net.cn/");
		buttons.add(btn2);
		
		return null;
	}
}
